'''
Created on 16 Apr 2012

@author: karulis
'''

from PySide import QtGui, QtCore
from AddTab import AddTab
from EditTab import EditTab
from DeleteTab import DeleteTab
from GroupsTab import GroupsTab

class TabDialog(QtGui.QDialog):
    '''
    classdocs
    '''

    refresh_gui = QtCore.Signal()

    def __init__(self, parent = None):
        '''
        Constructor
        '''
        super(TabDialog, self).__init__(parent)

        self.tabWidget = QtGui.QTabWidget()

        self.add_tab(AddTab(), "Add user")
        self.add_tab(DeleteTab(), "Delete user")
        self.add_tab(EditTab(), "Edit user")
        self.add_tab(GroupsTab(), "Manage groups")

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.tabWidget)
        self.setLayout(mainLayout)

        self.setWindowTitle("Linux users")
        self.tabWidget.setMinimumWidth(400)

    def add_tab(self, tab, description):
        tab.refresh.connect(self.refresh_gui)
        self.refresh_gui.connect(tab.refresh_gui)
        self.tabWidget.addTab(tab, description)
